<template>
  <div class="app-page">
    <!-- 头 -->
    <div class="app-header">
      <div class="app-title">
        <i :class="$route.meta.icon"></i> {{ $route.meta.title }}
      </div>
    </div>
    <div class="app-page-padding">
      <div class="app-section">
        <ul class="rs-clip-path">
          <li class="first"></li>
          <li class="second"></li>
          <li class="third"></li>
        </ul>
      </div>
      <div class="app-section">
        <!-- bidirectional data binding（双向数据绑定） -->
        <codemirror v-model="code" :options="cmOptions"></codemirror>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'StyleButton',
  data () {
    return {
      code: `
// rs-clip-path剪辑路径
.rs-clip-path {
  height: 100px;
  li {
    float: left;
    margin-right: 40px;
    width: 80px;
    height: 80px;
    background: #ccc;
    position: relative;
    &::before {
      position: absolute;
      content: "";
      left: 0;
      top: 0;
      width: 80px;
      height: 80px;
    }
  }
  .first {
    &::before {
      background-color: red;
      clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    }
  }
  .second {
    &::before {
      background-color: green;
      clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    }
  }
  .third {
    &::before {
      background-color: blue;
      clip-path: polygon(0% 50%, 40% 50%, 70% 0%, 100% 50%, 0% 100%);
    }
  }
}
      `,
      cmOptions: {
        // codemirror options
        tabSize: 4,
        mode: 'sass',
        theme: 'darcula',
        lineNumbers: true,
        line: true
        // more codemirror options, 更多 codemirror 的高级配置...
      }
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
// rs-clip-path剪辑路径
.rs-clip-path {
  height: 100px;
  li {
    float: left;
    margin-right: 40px;
    width: 80px;
    height: 80px;
    background: #ccc;
    position: relative;
    &::before {
      position: absolute;
      content: "";
      left: 0;
      top: 0;
      width: 80px;
      height: 80px;
    }
  }
  .first {
    &::before {
      background-color: red;
      clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    }
  }
  .second {
    &::before {
      background-color: green;
      clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    }
  }
  .third {
    &::before {
      background-color: blue;
      clip-path: polygon(0% 50%, 40% 50%, 70% 0%, 100% 50%, 0% 100%);
    }
  }
}
</style>
